import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/me/data/api/service_reqId_api.dart';
import 'package:casdon/modules/me/data/repository/me_repository.dart';
import 'package:casdon/modules/me/data/repository/me_repository_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class ServiceReqidUsecase {
  final MeRepository _repository;

  const ServiceReqidUsecase(this._repository);

  Future<List<ResponseServiceReqIdApi>> execute() async {
    try {
      var ret = await _repository.getServiceReqIdList();
      return ret ?? [];
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("ServiceReqidUsecase 失败", e.toString(), StackTrace.current);
      throw Exception("ServiceReqidUsecase 失败");
    }
  }
}

final serviceReqidUsecaseProvider = Provider(
  (ref) => ServiceReqidUsecase(ref.read(meRepositoryProvider)),
);
